/*
GeorgeLib
Collider.h
Under MIT License
*/

#ifndef __BOXCOLLIDER_H__
#define __BOXCOLLIDER_H__

#include "stdafx.h"
#include "Collider.h"

namespace GeorgeLib
{
	/// @brief A simple AABB collider
	class DLLEXPORT BoxCollider : public Collider
	{
	public:
		/// Constructor
		BoxCollider(void);
		/// Constructor : with a size value
		BoxCollider(vec3 size);
		/// Constructor : copy from an existing BoxCollider
		BoxCollider(const BoxCollider& box);
		~BoxCollider(void);

		/// Get the minimum coordinates of the bounding box
		vec3 min(void);
		/// Get the maximum coordinates of the bounding box
		vec3 max(void);
		/// Get the total size (length, height and width) of the bounding box
		/// This is always twice as large as the extents
		vec3 size(void);
		/// Set the size (length, height and width) of the bounding box
		void size(vec3 v);
		/// Get the extents of the bounding box
		/// This is always half of the size
		vec3 extents(void);

		/// Check if a Collider is intersecting with this Collider
		/// @param collider The other Collider to check containment with
		bool Collides(Collider* collider);

		/// Check if a Collider is within the bounds of this Collider
		/// @param collider The other Collider to check containment with
		bool Contains(Collider* collider);

		/// Check if a point in space is within the bounds of this Collider
		/// @param point The point to check containment with
		bool Contains(vec3 point);

		/// Makes sure a Collider is within the constrains of the bounds of this Collider
		/// @param collider The other Collider to contain
		void Contain(Collider* collider);

		/// Makes sure a point in space is within the bounds of this Collider
		/// @param point The point to contain
		void Contain(vec3& point);

		/// Check if a Collider is a BoxCollider
		/// @param collider The other Collider to check it's base class
		static bool IsBox(const Collider& collider);

		/// Cast a Collider pointer to a BoxCollider pointer
		/// @param collider The pointer to a Collider
		/// @remarks Return value will be NULL if collider is not a BoxCollider
		static BoxCollider* CastCollider(Collider* const collider);

	private:
		/// The size of the box, measured in the BoxCollider's local space
		vec3 _size;
		/// Half the size of the box
		vec3 _extents;
	};
}

#endif // __BOXCOLLIDER_H__